package com.shoujifeng.snowmusic.player;

import com.shoujifeng.snowmusic.player.R;
import com.shoujifeng.snowmusic.player.http.ServerAccess;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class LoginOutActivity extends Activity{
	private Button yesBtn;
	private Button noBtn;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login_out);
		init();
	}
	private void init(){
		yesBtn = (Button) findViewById(R.id.yesBtn);
		noBtn  = (Button) findViewById(R.id.noBtn);
		yesBtn.setOnClickListener(onClickListener);
		noBtn.setOnClickListener(onClickListener);
	}
	
	private OnClickListener onClickListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.yesBtn:
				 SharedPreferences spf = PreferenceManager.getDefaultSharedPreferences(LoginOutActivity.this);
			      Editor edit = spf.edit();
			      ServerAccess.uid = 0;
			      ServerAccess.code = "0";
			      
			      edit.putString(ServerAccess.CODE, "0");
			      edit.putString(ServerAccess.UID, "0");
			      edit.commit();
				
				Toast.makeText(LoginOutActivity.this, "退出成功!", Toast.LENGTH_SHORT)
				.show();
				
				finish();
				break;
				
			case R.id.noBtn:
				finish();
				break;	
			default:
				break;
			}
		}
	};
}
